<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            *{
                margin: 0px;
                padding: 0px;
                list-style: none;
            }
            textarea{
                width: 700px;
                 outline: none;
                margin:0px auto;              
                resize: none;
                display: block; 
               
            }
            button{
                width: 700px;
               
                margin:30px auto;
                
                display: block;
                border:none;
                background:aqua;
            
                line-height: 40px;
                cursor: pointer;
                
                outline: none;
            }
            ul{
                width: 700px;
              
                margin:30px auto;
            }
            li{
                border:1px solid skyblue;
                padding:20px;
                position: relative;
              
            }
            
            span{
                position: absolute;
                right:-3px;
                top: -19px;
                cursor: pointer;
            }
        </style>
    </head>
    <body>
        <textarea name="" id="txt" cols="30" rows="10"></textarea>
        <button id="btn">发布微博</button>
        <ul id="box">
            <li>
                咕咕咕咕
                <p>2021-06-12</p>
               
                <span onclick="del(this)">X</span>
            </li>
        </ul>
        <script>
            
            var txt=document.getElementById('txt'); 
            var main=document.getElementById('main');
            var btn=document.getElementById('btn');

            var year=new Date().getFullYear();
            var month=new Date().getMonth()+1;
            var date=new Date().getDate()
           
   
            btn.onclick=function(){
            
                var val=txt.value;
       
                var tag=document.createElement('li');
              
                tag.innerHTML=`${val}
               <p>${year}-${month}-${date}</p>
                <span onclick="del(this)">x</span>`;
     
                box.appendChild(tag)
            }

 
    //if(val=txt.value){
        this.document='';
    }
    


            function del(a){
           
                a.parentNode.parentNode.removeChild(a.parentNode)
            }
        </script>
    </body>
</html>